﻿var Weeks="";
var FromTimes="";
var ToTimes="";

function pageLoad(sender, args)
{    elVal();
    Weeks=oWeek;
    FromTimes=oFTime;
    ToTimes=oTTime;     
}
function cexTime(a,b)
{
    $TTime$(a,b,Weeks,FromTimes,ToTimes);
} 

//判断选择的行业来显示相对应的
function OccupationCatChange()
{
    var obj=document.getElementById("OccupationCat");
	var obj1 = document.getElementById("Occupation1");
	var obj2 = document.getElementById("Occupation2");	
	var selv = obj.value;
	if(selv==""||selv=="3")
	{
		obj1.style.display = 'none';
		obj2.style.display = 'none';
	}
	else if(selv=="1")
	{
		obj1.style.display = 'none';
		obj2.style.display = '';
	}
	else if(selv=="2")
	{
		obj1.style.display = '';
		obj2.style.display = 'none';
	}
}
//初始化Favorite OccupationCat并判断显示的行业。
function elVal()
{
     
    if(OccupationCat>4)
    {
        $get("OccupationCat").value="";
    }

    if(Occupation!=null&&OccupationCat==2)
    {
        $get("Occupation2").style.display = 'none';
        $get("Occupation1").style.display = '';

    }
    else if(Occupation!=null&&OccupationCat==1)
    {
         $get("Occupation1").style.display = 'none';
         $get("Occupation2").style.display = '';
    }        
}

//保存我的个人档案
function SavePersonal()
{
    if(TT_c!="")
    {
      Weeks=TT_c;
      FromTimes=TT_d;
      ToTimes=TT_e;  
    }
    showProgressBar(true);
    var vlid=true;
    var re=/http(s)?:\/\/[^s]*/;
    var re1=/[^!@#\$%\^\*\(\)\+\,\:\;\&\.\{\}\[\]\?]/;
    var re2=/\d{1,4}-\d{1,4}-\d{1,4}/;
    $("SBOD").style.display='none';
    $("SNickname").style.display='none';
    $("SCountry").style.display='none';
    $("SNationality").style.display='none';
    $('SWeek').style.display='none';
    if($("Nickname").value=="")
    {
        vlid=false;
        $("SNickname").style.display='';
        $("SNickname").innerHTML="<br />"+SNickname2;
    }
    else if($("Nickname").value.search(re1))
    {
        vlid=false;
        $("SNickname").style.display='';
        $("SNickname").innerHTML="<br />"+SNickname1;
    }
    if($("Country").value=="")
    {
        vlid=false;
        $("SCountry").style.display='';
    }
    if($("Nationality").value=="")
    {
        vlid=false;
        $get("SNationality").style.display='';
    }
    if(BODCID.value.search(re2))
    {
        vlid=false;
        $get("SBOD").style.display='';
    }
    if(Weeks=="")
    {
        $('SWeek').style.display='';
        vlid=false;
    }     
    if($("PersonalWebpage").value.search(re)&&$("PersonalWebpage").value!="")
    {
        $('SPersonalWebpage').style.display='';
        vlid=false;
    } 
    if(!vlid) {showProgressBar(false); return;}
    $get("btnSave").disabled = true;
    var Nickname=$get("Nickname").value;
    var Gender=$get("Radio4").checked ? 1 : 0;
    var BOD=BODCID.value;
    var IsShowBod=$get("ShowBodID").checked ? false : true;
    var Country=$get("Country").value;
    var City=$get("City").value;
    var Nationality=$get("Nationality").value;
    var Hometown=$get("Hometown").value;
    var Marriage=$get("MarriageID").value;
    var  uOccupationCat=$get("OccupationCat").value;    
    var  uOccupation="";
    if(uOccupationCat==1)
    {
        uOccupation=$get("Occupation2").value;
    }
    else if(uOccupationCat==2)
    {
        uOccupation=$get("Occupation1").value;
    }
    var Education=$get("Education").value;
    var PersonalWebpage=$get("PersonalWebpage").value;
    var uFavorite=0;
    var k=1;
    for (i = 0; i < 11; i++)
    {
        if($get("Checkbox"+k+"").checked==true)
        {
            uFavorite += parseInt($get("Checkbox"+k+"").value);
        }
        k++;
    }    
    var Introduction=$get("Introduction").value;
    WebServices.My.UpdatePersonalProf(Nickname,Nationality,Hometown,Country,City,Gender,BOD,IsShowBod,Introduction,Education,uOccupationCat,uOccupation,PersonalWebpage,Marriage,uFavorite,Weeks,FromTimes,ToTimes,timezone,onsucc);

 }
function onsucc(result)
{
    showProgressBar(false);
    if(result.State)
    {
        $get("MessagesBox").style.display='';
        $get("MessageImg").src = MessageImageS;
        $get("MessageText").innerHTML = MessageTextS;
    }
    else
    {
        $get("MessagesBox").style.display='';
        $get("MessageImg").src = MessageImageF;
        $get("MessageText").innerHTML = MessageTextF;        
    }    
    $get("btnSave").disabled = false;    
    scroller("MessagesBox",100);
}